package com.xquant.transaction_management_system.service.Impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xquant.transaction_management_system.mapper.AccountMapper;
import com.xquant.transaction_management_system.mapper.FinancialInstrumentsMapper;
import com.xquant.transaction_management_system.model.PO.Account;
import com.xquant.transaction_management_system.model.PO.FinancialInstruments;
import com.xquant.transaction_management_system.service.AccountService;
import com.xquant.transaction_management_system.service.FinancialInstrumentsService;
import javafx.scene.LightBase;
import org.springframework.stereotype.Service;


import java.util.List;

@Service
public class FinancialInstrumentsServiceImpl extends ServiceImpl<FinancialInstrumentsMapper, FinancialInstruments> implements FinancialInstrumentsService {

    @Override
    public IPage<FinancialInstruments> selectPageByDebentureCode(Page<FinancialInstruments> pageParam, String debentureCode) {
        QueryWrapper<FinancialInstruments> queryWrapper = new QueryWrapper<>();
        System.out.println(debentureCode);
        queryWrapper.like("debenture_code",debentureCode);

        IPage<FinancialInstruments> pages = baseMapper.selectPage(pageParam, queryWrapper);
        return pages;
    }

    @Override
    public IPage<FinancialInstruments> selectPage(Page<FinancialInstruments> pageParam) {
        QueryWrapper<FinancialInstruments> queryWrapper = new QueryWrapper<>();
        IPage<FinancialInstruments> pages = baseMapper.selectPage(pageParam, queryWrapper);
        return pages;
    }

    @Override
    public FinancialInstruments getByCode(String debentureCode) {
        QueryWrapper<FinancialInstruments> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("debenture_code",debentureCode);
        FinancialInstruments financialInstruments = baseMapper.selectOne(queryWrapper);
        return financialInstruments;
    }

    @Override
    public IPage<FinancialInstruments> getByAccountPage(Page<FinancialInstruments> pageParam, String transactionAccount) {
        QueryWrapper<FinancialInstruments> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("transaction_account",transactionAccount);
        IPage<FinancialInstruments> pages = baseMapper.selectPage(pageParam, queryWrapper);
        return pages;
    }

    @Override
    public List<FinancialInstruments> getByConfigID(Long congigurationId) {
        QueryWrapper<FinancialInstruments> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("congiguration_id",congigurationId);
        List<FinancialInstruments> serviceById = baseMapper.selectList(queryWrapper);
        return serviceById;
    }

    @Override
    public IPage<FinancialInstruments> getByAccountAndCodePage(Page<FinancialInstruments> pageParam, QueryWrapper<FinancialInstruments> queryWrapper) {
        return baseMapper.selectPage(pageParam,queryWrapper);
    }
}
